﻿using System;
using SlimDX.Direct3D11;
using SlimDX;
using Buffer = SlimDX.Direct3D11.Buffer;
using System.Drawing;

namespace InsTron
{
    class SimpleModel
    {
        private Buffer vertexBuffer;
        private int vertexCount;
        private int vertexSize;


        public SimpleModel(Buffer vertexBuffer, int vertexCount, int vertexSize)
        {
            this.vertexBuffer = vertexBuffer;
            this.vertexCount = vertexCount;
            this.vertexSize = vertexSize;
        }


        public void Render(DeviceContext deviceContext, EffectTechnique technique)
        {
            deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, vertexSize, 0));
            for (int i = 0; i < technique.Description.PassCount; i++)
            {
                technique.GetPassByIndex(i).Apply(deviceContext);
                deviceContext.Draw(vertexCount, 0);
            }
        }


        public void DisposeAll()
        {
            vertexBuffer.Dispose();
        }
    }
}
